import java.io.IOException;
import java.util.Properties;

/**
 * @author 徒有琴
 */
public class MyBeanFactory {
    private static Properties properties = new Properties();

    static {
        try {
            properties.load(MyBeanFactory.class.getResourceAsStream("bean.properties"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static Object getBean(String name) throws ClassNotFoundException,
            IllegalAccessException, InstantiationException {
        String className=properties.getProperty(name);
        if(className!=null){
            Class clazz=Class.forName(className);
            return clazz.newInstance();
        }
        return null;
    }
}
